﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kaskelot.Services.Model;

namespace Stockholm.SOA.Kaskelot.WCF.ServiceImplementation.Mapping
{
	public static class SkyltExtensions
	{
		public static DataContracts.Skylt ToContract(this Skylt entity)
		{
			DataContracts.Skylt b = new DataContracts.Skylt();

			CopyFromEntity(entity, b, false);

			return b;
		}

		public static DataContracts.Skylt ToMinimalContract(this Skylt entity)
		{
			DataContracts.Skylt b = new DataContracts.Skylt();

			CopyFromEntity(entity, b, true);

			return b;
		}

		public static Skylt ToEntity(this DataContracts.Skylt b)
		{
			Skylt entity = new Skylt();

			CopyToEntity(b, entity);

			return entity;
		}

		public static void UpdateEntity(this Skylt entity, DataContracts.Skylt b)
		{
			CopyToEntity(b, entity);
		}

		private static void CopyFromEntity(Skylt from, DataContracts.Skylt to, bool minimal)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;

			to.ByggnadId = from.ByggnadId;
			to.Beskrivning = from.Beskrivning;
			to.LiggerIVaskan = from.LiggerIVaskan;

			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;
		}

		private static void CopyToEntity(DataContracts.Skylt from, Skylt to)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;

			to.LiggerIVaskan = from.LiggerIVaskan;
			to.Beskrivning = from.Beskrivning;
			to.ByggnadId = from.ByggnadId;

			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;
		}
	}
}
